import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { resolve } from 'node:path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
    // 添加库模式配置
    build: {
      outDir: "lib",
      minify: false,
      lib: {
        entry: resolve(__dirname, "src/index.ts"),
        name: "JcyComponent",
        fileName: "jcy-component",
        // 导出模块格式
        formats: ["es", "umd", "iife"],
      },
      rollupOptions: {
        external: ["vue"],
        output: {
          globals: {
            vue: "Vue",
          },
        },
      },
    },
})
